package com.mdb.open.epay.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitConfig {
    public static final String EXCHANGE_EPAY = "epay.exchange";
    public final static String QUEUE_EPAY_QPORDER_RETRY = "epay.qporder.retry";
    public final static String QUEUE_EPAY_QPREFUND_ORDER_RETRY = "epay.qprefund.order.retry";

    @Bean
    TopicExchange exchange() {
        return new TopicExchange(EXCHANGE_EPAY);
    }

    @Bean
    public Queue ePayQpOrderRetry() {
        return new Queue(QUEUE_EPAY_QPORDER_RETRY);
    }

    @Bean
    public Queue epayQprefundOrderRetry() {
        return new Queue(QUEUE_EPAY_QPREFUND_ORDER_RETRY);
    }

    @Bean
    Binding bindingQpOrderQueue(Queue ePayQpOrderRetry, TopicExchange exchange) {
        return BindingBuilder.bind(ePayQpOrderRetry).to(exchange).with(QUEUE_EPAY_QPORDER_RETRY);
    }

    @Bean
    Binding bindingQpRefundOrderQueue(Queue epayQprefundOrderRetry, TopicExchange exchange) {
        return BindingBuilder.bind(epayQprefundOrderRetry).to(exchange).with(QUEUE_EPAY_QPREFUND_ORDER_RETRY);
    }
}
